<?php

namespace api\libs\swoft;

use api\libs\swoft\core\SwoftCore;
use api\libs\swoft\ifc\SwoftClient;
use yii\helpers\Json;

class SwoftOrder extends SwoftClient
{
    public function getDispatchList($arr_request, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/dispatch-list';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array_merge($arr_request, ['token' => $access_token]);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_GET;
        return $this->sendRequest($options);
    }
    
    public function getList($arr_request, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/list';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array_merge($arr_request, ['token' => $access_token]);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_GET;
        return $this->sendRequest($options);
    }

    public function getOne($id, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/' . urldecode($id);
        $options[SwoftCore::SWOFT_QUERY_STRING] = ['token' => $access_token];
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_GET;
        return $this->sendRequest($options);
    }

    public function getCount($arr_request, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/count';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array_merge($arr_request, ['token' => $access_token]);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_GET;
        return $this->sendRequest($options);
    }
    
    public function getCheckList($arr_request, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/check-list';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array_merge($arr_request, ['token' => $access_token]);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_GET;
        return $this->sendRequest($options);
    }

    public function getApprovalList($arr_request, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/approval-list';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array_merge($arr_request, ['token' => $access_token]);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_GET;
        return $this->sendRequest($options);
    }
    
    public function caseHandle($data, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/case-handling';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array('token' => $access_token);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_POST;
        $options[SwoftCore::SWOFT_CONTENT_TYPE] = 'application/x-www-form-urlencoded';
        $options[SwoftCore::SWOFT_CONTENT] = http_build_query($this->convertParams($data));
        return $this->sendRequest($options);
    }

    public function preChargeBack($data, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/pre-charge-back';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array('token' => $access_token);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_POST;
        $options[SwoftCore::SWOFT_CONTENT_TYPE] = 'application/x-www-form-urlencoded';
        $options[SwoftCore::SWOFT_CONTENT] = http_build_query($this->convertParams($data));
        return $this->sendRequest($options);
    }

    public function chargeBack($data, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/charge-back';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array('token' => $access_token);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_POST;
        $options[SwoftCore::SWOFT_CONTENT_TYPE] = 'application/x-www-form-urlencoded';
        $options[SwoftCore::SWOFT_CONTENT] = http_build_query($this->convertParams($data));
        return $this->sendRequest($options);
    }

    public function preDelay($data, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/pre-delay';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array('token' => $access_token);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_POST;
        $options[SwoftCore::SWOFT_CONTENT_TYPE] = 'application/x-www-form-urlencoded';
        $options[SwoftCore::SWOFT_CONTENT] = http_build_query($this->convertParams($data));
        return $this->sendRequest($options);
    }

    public function delay($data, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/delay';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array('token' => $access_token);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_POST;
        $options[SwoftCore::SWOFT_CONTENT_TYPE] = 'application/x-www-form-urlencoded';
        $options[SwoftCore::SWOFT_CONTENT] = http_build_query($this->convertParams($data));
        return $this->sendRequest($options);
    }

    public function complete($data, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/complete';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array('token' => $access_token);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_POST;
        $options[SwoftCore::SWOFT_CONTENT_TYPE] = 'application/x-www-form-urlencoded';
        $options[SwoftCore::SWOFT_CONTENT] = http_build_query($this->convertParams($data));
        return $this->sendRequest($options);
    }

    public function appointUser($data, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/appoint-user';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array('token' => $access_token);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_POST;
        $options[SwoftCore::SWOFT_CONTENT_TYPE] = 'application/x-www-form-urlencoded';
        $options[SwoftCore::SWOFT_CONTENT] = http_build_query($this->convertParams($data));
        return $this->sendRequest($options);
    }

    public function dispatch($data, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/dispatch';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array('token' => $access_token);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_POST;
        $options[SwoftCore::SWOFT_CONTENT_TYPE] = 'application/x-www-form-urlencoded';
        $options[SwoftCore::SWOFT_CONTENT] = http_build_query($this->convertParams($data));
        return $this->sendRequest($options);
    }

    public function orderPassed($data, $access_token) {
        $options[SwoftCore::SWOFT_RESOURCE] = $this->getBaseUri() . 'web/case/order-passed';
        $options[SwoftCore::SWOFT_QUERY_STRING] = array('token' => $access_token);
        $options[SwoftCore::SWOFT_METHOD] = SwoftCore::SWOFT_HTTP_POST;
        $options[SwoftCore::SWOFT_CONTENT_TYPE] = 'application/x-www-form-urlencoded';
        $options[SwoftCore::SWOFT_CONTENT] = http_build_query($this->convertParams($data));
        return $this->sendRequest($options);
    }
}